package homework5;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * 1. 定义学生类包含学号、姓名和成绩三个属性；
 * 2. 重写hashCode和equals方法，选中学号即可
 * 3. 定义LinkedHashMap对象，键是学生对象，值是地址
 * 4. 创建学生对象存入数据
 * 5. 遍历查看结果
 */
public class Test5 {
    public static void main(String[] args) {
        //创建学生对象
        Student student1 = new Student(1, "张三", 80);
        Student student2 = new Student(1, "王五", 89);
        Student student3 = new Student(2, "麻子", 79);
        Student student4 = new Student(3, "李四", 70);

        String adress1 = "北京";
        String adress2 = "上海";
        String adress3 = "南京";
        String adress4 = "广西";

        Map<Student, String> map = new LinkedHashMap<>();
        map.put(student1, adress1);
        map.put(student2, adress2);
        map.put(student3, adress3);
        map.put(student4, adress4);

        Set<Student> students = map.keySet();
        for (Student student : students) {
            System.out.println("学生信息：学号-" + student.getStudyNum() + "，姓名-" + student.getName() + "，成绩-" + student.getScore()
                    + "，地址-" + map.get(student));
        }
    }
}
